package is.ru.server;

/**
 * Created in IntelliJ IDEA.
 * Students: Jón Geir Sigurbjörnsson, Kristinn Helgi Hilmarsson, Jón Rúnar Arnarsson
 * Class: T-408-STNE, Stýrikerfi og netkerfi, 2011-1
 * Project: Programming assignment 3: HTTP web server
 * Date: 16.3.2011
 * Time: 20:17
 */

public class HttpRuServer
{
    public static void main(String[] args)
    {
        // Basic info is hardcoded so if the user forgot to put some args the program will run with the given settings
        String protocol = "tcp";
        int port = 1234;

        // Info worked from args
        if (args.length == 1)
        {
            protocol = args[0];
        }
        else if (args.length == 2)
        {
            protocol = args[0];
            port = Integer.parseInt(args[1]);
        }
        // If tcp, then start the TCPConnectionHandler
        if (protocol.equalsIgnoreCase("tcp"))
        {
            TCPConnectionHandler handler = new TCPConnectionHandler(port);
            handler.start();
        }
        // If udp, then start the UDPConnectionHandler
        else if (protocol.equalsIgnoreCase("udp"))
        {
            UDPConnectionHandler handler = new UDPConnectionHandler(port);
            handler.start();
        }
    }
}
